import Vue from 'vue'
import Router from 'vue-router'
Vue.use(Router)
import UserLayout from '@/layouts/UserLayout.vue'
export const asyncRouterMap = [{
		path: '/system',
		name: 'system',
		component: () => import( /* webpackChunkName: "PageView" */
			'@/layouts/PageView.vue'),
		meta: {
			keepAlive: true,
			title: '系统管理',
			icon: 'card_membership',
		},
		redirect: '/system/accountlist',
		children: [{
				path: '/system/accountlist',
				name: 'accountlist',
				component: () => import( /* webpackChunkName: "account" */
					'./views/system/accountlist.vue'),
				meta: {
					keepAlive: true,
					title: '用户列表',
					icon: 'account_box',
				}
			},
			{
				path: '/system/nationlinelist',
				name: 'nationlinelist',
				component: () => import( /* webpackChunkName: "nationline" */
					'./views/system/nationlinelist.vue'),
				meta: {
					keepAlive: true,
					title: '国家线列表',
					icon: 'account_box',
				}
			},
			{
				path: '/system/courselist',
				name: 'courselist',
				component: () => import( /* webpackChunkName: "nationline" */
					'./views/system/courselist.vue'),
				meta: {
					keepAlive: true,
					title: '推荐课程列表',
					icon: 'account_box',
				}
			},
			{
				path: '/system/schoollist',
				name: 'schoollist',
				component: () => import( /* webpackChunkName: "schoollist" */
					'./views/system/schoollist.vue'),
				meta: {
					keepAlive: true,
					title: '学校列表',
					icon: 'account_box',
				}
			},
			{
				path: '/system/configllist',
				name: 'configllist',
				component: () => import( /* webpackChunkName: "configllist" */
					'./views/system/configllist.vue'),
				meta: {
					keepAlive: true,
					title: '配置列表',
					icon: 'account_box',
				}
			}

		]
	},
	{
		path: '/retrial',
		name: 'retrial',
		component: () => import( /* webpackChunkName: "PageView" */
			'@/layouts/PageView.vue'),
		meta: {
			keepAlive: true,
			title: '估分管理',
			icon: 'card_membership',
		},
		redirect: '/retrial/estimatellist',
		children: [{
				path: '/retrial/estimatellist',
				name: 'estimatellist',
				component: () => import( /* webpackChunkName: "account" */
					'./views/retrial/estimatellist.vue'),
				meta: {
					keepAlive: true,
					title: '估分列表',
					icon: 'account_box',
				}
			}, {
				path: '/retrial/retriallist',
				name: 'retriallist',
				component: () => import( /* webpackChunkName: "account" */
					'./views/retrial/retriallist.vue'),
				meta: {
					keepAlive: true,
					title: '复试线列表',
					icon: 'account_box',
				}
			}

		]
	},
	{
		path: '/question',
		name: 'question',
		component: () => import( /* webpackChunkName: "PageView" */
			'@/layouts/PageView.vue'),
		meta: {
			keepAlive: true,
			title: '题目管理',
			icon: 'card_membership',
		},
		redirect: '/question/questionllist',
		children: [{
			path: '/question/questionllist',
			name: 'questionllist',
			component: () => import( /* webpackChunkName: "questionllist" */
				'./views/question/questionllist.vue'),
			meta: {
				keepAlive: true,
				title: '题目列表',
				icon: 'account_box',
			}
		}, ]
	}

];
export const constantRouterMap = [{
		path: '/',
		component: UserLayout,
		redirect: '/user',
		name: 'home',
		hidden: true,
		meta: {
			title: '首页',
			icon: 'home'
		}
	}, {
		path: '/user',
		component: UserLayout,
		redirect: '/user/login',
		hidden: true,
		children: [{
				path: '/user/login',
				name: 'login',
				component: () => import( /* webpackChunkName: "user" */ '@/views/user/Login')
			}

		]
	}, {
		path: '/redirect',
		name: 'redirect',
		component: () => import( /* webpackChunkName: "PageView" */ '@/layouts/PageView.vue'),
		hidden: true,
		children: [{
			name: 'redirect',
			path: '/redirect/:path*',
			component: () =>
				import('@/components/redirect.vue')
		}]
	},
	{
		path: '/404',
		hidden: true,
		component: () =>
			import('@/components/404/index.vue')
	}

]

const router = new Router({
	// mode: 'hash',
	base: process.env.BASE_URL,
	routes: [...constantRouterMap, ...asyncRouterMap]
})
const originalPush = Router.prototype.push
/* 处理重复点击的问题 */
Router.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}
export default router
